home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
zapscrn.zip
/
ZAP.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-15
|
18KB
|
586 lines
page 60,132
; Copyright (C) 1988 Mark Adler Pasadena, CA
; All rights reserved.
title ZAP - screen saver for the EGA or VGA
comment #
Version history -
1.0 18 Nov 1988 First public version
1.1 14 Dec 1988 Fixed bug in EGAZAP
ZAP -
ZAP is a resident utility that blanks the screen after a specified
period of inactivity. The ZAP.ASM program actually generates two
different programs depending on the assembler options: EGAZAP and
VGAZAP. The first is for the IBM Enhanced Graphics Adapter or
compatibles, and the second is for IBM PS/2's, the IBM Video Graphics
Adpater, and comaptibles. From here on, ZAP will be used to mean
EGAZAP or VGAZAP, whichever is appropriate for your hardware.
To install ZAP, simply put the command ZAP in your AUTOEXEC.BAT file.
From then on, when there is five minutes of inactivity at the
keyboard, ZAP will blank the screen until any key (even just a shift
key) is hit. The time can be changed with a command line option which
specifies the time in seconds. For example:
zap 600
will install ZAP (if not already installed) and change the time to 10
minutes.
You can also turn the installed ZAP on and off using ZAP. For example:
zap off
will turn off the installed ZAP, so it will not blank the screen. Then
the command:
zap on
will turn ZAP back on.
ZAP can also be installed in the "off" state, awaiting a "zap on"
command, simply by using:
zap off
in AUTOEXEC.BAT. You can also specify on or off along with a new
inactivity time. For example, the command:
zap off 600
in AUTOEXEC.BAT will install ZAP in the off state with a 10 minute
inactivity time. Then a subsequent "zap on" will turn it on. The time
must be in the range of one to 3600 seconds (one hour). Specifying a
new time does not change whether ZAP is enabled or not and turning ZAP
on or off does not change the time. Also, the two options can be in
either order. For example, "zap 600 off" does the same thing as the
example above. If ZAP is already installed, subsequent invocations of
ZAP will not install it again. If the command:
zap
is entered after ZAP is already installed, this has the same effect as
the command "zap on", that is it turns on ZAP if it was off.
ZAP turns the display back on not only when any key is hit, but also if
any video BIOS calls (int 10h) are made. Since most application
programs seem to bypass the BIOS for video, this added feature has
little effect.
There are a few, rare programs that also completely take the keyboard
from the BIOS, in which case ZAP can no longer find out when keystrokes
occur. An example is STSC APL (a programming language). In this case,
ZAP will blank your display, even though you have been merrily typing
away for the last five minutes in the application. And the only way to
get the display back on is to return to DOS (assuming you can get out
while driving the application blindfolded). For such applications, you
should include the commands "zap off" and "zap on" in a batch file that
runs the application to disable ZAP before entering and enabling ZAP
after leaving the application. You will quickly discover if you have
any such applications.
This program assumes that the current display is the (only) active
display, but does not check for it either at installation or when
running.
For the EGA, the screen is blanked by setting the number of characters
displayed to one, and the start of horizontal blanking to the first
character. The number of displayed characters needs to be small (set
to one for convenience) since the horizontal blanking interval is
limited to 32 characters. The screen is restored by getting the
current screen mode information from the BIOS and from that and the
table of Start Horizontal Blanking values in this program (copied from
the BIOS listing---not entirely kosher, but the only decent approach),
the proper register values are restored.
For the VGA, the screen is blanked and restored using the Screen Off
bit in the Clocking Mode Register (port 0x3c4, address 01, bit 5).
To minimize the resident memory required, this program is assembled
separately for the EGA or VGA. When assembling, define the symbol EGA
or VGA in the command line using /d (see the manual for MASM or TASM).
If no symbol is defined, you will be warned and the resulting .COM file
will be asssembled for the VGA. For example, the commands:
tasm /dega zap
tlink /t zap,egazap
tasm /dvga zap
tlink /t zap,vgazap
will generate EGAZAP.COM and VGAZAP.COM, assuming that you have the
Borland Turbo Assembler.
The fact that the number of bytes in VGAZAP (666) is the same as
Reagan's retirement home's address in Bel Air should be given no
religious significance.
#
ifndef VGA
ifndef EGA
%out !No display specified---assembling for the VGA.
endif
endif
;
; Macros for blanking screens.
;
egaoff macro
local ismono,CRTMON,CRTCOL
CRTMON equ 03B4h ;;CRT controller register in Mono mode.
CRTCOL equ 03D4h ;;CRT controller register in Color mode.
push AX ;;Save registers.
push BX
push CX
push DX
mov AH,12h ;;Get Mono/Color in BH.
mov BL,10h
pushf ;;Do Int 10h
push CS
call altvid
mov DX,CRTMON ;;Point DX to CRT port in Mono mode.
test BH,BH ;;See if color mode.
jnz ismono ;;If not, then DX is correct.
mov DX,CRTCOL ;;If color, use color address.
ismono:
mov AX,1 ;;Set number of characters to 1.
out DX,AX
inc AX ;;Set horizontal start of blanking to char 0.
out DX,AX
pop DX ;;Restore registers.
pop CX
pop BX
pop AX
endm
egaon macro
local ismono,enhance,shbget,tbl,CRTMON,CRTCOL
CRTMON equ 03B4h ;;CRT controller register in Mono mode.
CRTCOL equ 03D4h ;;CRT controller register in Color mode.
;;
;; Restore the display by getting the correct register values and
;; setting them.
;;
;; save registers used by routine, except AX.
push BX
push CX
push DX
;; get CRT port, switch setting.
mov AH,12h ;;Get switch setting into CL, Mono/Color in BH.
mov BL,10h
pushf ;;Do Int 10h
push CS
call altvid
mov DX,CRTMON ;;Point DX to CRT port in Mono mode.
test BH,BH ;;See if color mode.
jnz ismono ;;If not, then DX is correct.
mov DX,CRTCOL ;;If color, use color address.
ismono:
;; get values for CRT registers 1 and 2.
mov AH,0Fh ;;Get mode into AL, columns into AH.
pushf ;;Do Int 10h
push CS
call altvid
dec AH ;;Compute Horizontal Display End setting (1).
cmp AL,3 ;;See if color mode.
ja shbget ;;If not, go on to get Start Horiz Blank (2).
cmp CL,3 ;;See if in secondary enhanced mode.
je enhance ;;If so, use enhanced 0-3 settings.
cmp CL,9 ;;See if in primary enhanced mode.
jne shbget ;;If not, use normal 0-3 settings.
enhance:
add AL,11h ;;Add offset for table.
shbget:
mov BX,(offset trap)+(tbl-set) ;;Point to table.
xlat byte ptr CS:tbl ;;Get Start Horizontal Blank setting.
;; Now AH is CRT register 1, AL is register 2 - set them.
mov CL,AL ;;Save register 2 setting.
mov AL,1 ;;Set register 1.
out DX,AX
mov AH,CL ;;Get register 2 setting.
inc AX ;;Set register 2.
out DX,AX
;; done, restore registers and return.
pop DX
pop CX
pop BX
ret
;;Start horiz blank values for modes 0-10, 0*-3*.
tbl label byte
db 2Dh,2Dh,5Ch,5Ch,2Dh,2Dh,59h,56h ;;0-7.
db 2Dh,2Dh,2Dh,5Ch,56h,2Dh,59h,56h,53h ;;8-10h.
db 2Bh,2Bh,53h,53h ;;0*-3*.
endm
vgaoff macro
local CRTS